// utils/common.js
import Taro from '@tarojs/taro'

// eslint-disable-next-line import/prefer-default-export
export function getWindowHeight(HEIGHT,showTabBar = true) {
  // console.log(height)
  const SELECT_HEIGHT = HEIGHT
  const TAB_BAR_HEIGHT = 50
  const NAVIGATOR_HEIGHT = 44
  const info = Taro.getSystemInfoSync()
  const { windowHeight, statusBarHeight } = info
  const tabBarHeight = showTabBar ? TAB_BAR_HEIGHT : 0

  if (process.env.TARO_ENV === 'rn') {
    return windowHeight - statusBarHeight - NAVIGATOR_HEIGHT - tabBarHeight - SELECT_HEIGHT
  }

  if (process.env.TARO_ENV === 'h5') {
    return `${windowHeight - tabBarHeight - SELECT_HEIGHT}px`
  }

  return `${windowHeight  - SELECT_HEIGHT}px`
}
